const app = getApp()
const CONFIG = require('../../config.js')
const WXAPI = require('../../wxapi/main')
Page({
	data: {
    balance:0.00,
    freeze:0,
    wdzyj:0,
    score_sign_continuous:0
  },
	onLoad() {
    
	},	
  onShow() {
    let that = this;
    this.getUserApiInfo();
    this.getUserAmount();
    this.getchoujiang(); 
  },
  aboutUs : function () {
    wx.showModal({
      title: '关于我们',
      content: '本系统是逐峰建材小程序，祝大家使用愉快！',
      showCancel:false
    })
  },
  getUserApiInfo: function () {
    var that = this;
    WXAPI.userDetail(wx.getStorageSync('token')).then(function (res) {
      if (res.type == 'success') {
        let _data = {}
        _data.userinfo = res.resultData.row     
        that.setData(_data);
      }
    })
  },
  getUserAmount: function () {
    var that = this;
    WXAPI.userAmount(wx.getStorageSync('token')).then(function (res) {
      if (res.type == 'success') {
        that.setData({
          balance: (res.resultData.row.yue + res.resultData.row.dbyue).toFixed(2)
        });
      }
    })
    WXAPI.userwdz().then(function (res) {
      if (res.type == 'success') {
        that.setData({
          wdzyj: res.resultData.row.toFixed(2)
        });
      }
    })
  },
  getchoujiang: function () {
    var that = this;
    WXAPI.choujianglist().then(function (res) {
      if (res.type == 'success') {
        let _data = {}
        _data.choujianglist = res.resultData.rows
        that.setData(_data);
      }
    })
  },
  relogin:function(){
    app.getWxUser()
  },
  goAsset: function () {
    wx.navigateTo({
      url: "/pages/asset/index"
    })
  },
  gophone: function () {
    wx.navigateTo({
      url: "/pages/userupdate/index"
    })
  },
  goScore: function () {
    wx.navigateTo({
      url: "/pages/score/index"
    })
  },
  goYj: function () {
    wx.navigateTo({
      url: "/pages/fx/commisionLog"
    })
  },
  goOrder: function (e) {
    wx.navigateTo({
      url: "/pages/order-list/index?type=" + e.currentTarget.dataset.type
    })
  }
})